package online.heycm.rbac.common.converter;

import online.heycm.rbac.common.constant.Dictionary;
import online.heycm.rbac.common.entity.InterfaceDef;
import online.heycm.rbac.domain.basic.repository.entity.BasicDictionary;
import online.heycm.rbac.domain.basic.repository.entity.BasicParamCfg;
import online.heycm.rbac.domain.basic.repository.entity.BasicRbacInterface;
import online.heycm.rbac.domain.basic.repository.entity.BasicRbacResource;
import online.heycm.rbac.domain.basic.repository.entity.BasicRbacRole;
import online.heycm.rbac.domain.user.repository.entity.UserProfile;
import online.heycm.rbac.param.basic.DictionaryAddReq;
import online.heycm.rbac.param.basic.DictionaryEditReq;
import online.heycm.rbac.param.basic.DictionaryRes;
import online.heycm.rbac.param.basic.InterfaceAddReq;
import online.heycm.rbac.param.basic.InterfaceEditReq;
import online.heycm.rbac.param.basic.InterfaceRes;
import online.heycm.rbac.param.basic.ParamCfgAddReq;
import online.heycm.rbac.param.basic.ParamCfgEditReq;
import online.heycm.rbac.param.basic.ParamCfgRes;
import online.heycm.rbac.param.basic.ResourceAddReq;
import online.heycm.rbac.param.basic.ResourceEditReq;
import online.heycm.rbac.param.basic.ResourceRes;
import online.heycm.rbac.param.basic.RoleAddReq;
import online.heycm.rbac.param.basic.RoleEditReq;
import online.heycm.rbac.param.basic.RoleRes;
import online.heycm.rbac.param.user.ConsoleResourceRes;
import online.heycm.rbac.param.user.UserAddReq;
import online.heycm.rbac.param.user.UserDetailRes;
import online.heycm.rbac.param.user.UserEditReq;
import online.heycm.rbac.param.user.UserPageRes;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * mapstruct
 *
 * @author hey
 * @version 1.0
 * @date 2024/1/12 9:59
 */
@Mapper(imports = {DictConverter.class, Dictionary.class})
public interface RbacConverter {
    RbacConverter INST = Mappers.getMapper(RbacConverter.class);

    BasicDictionary convert(DictionaryAddReq req);

    BasicDictionary convert(DictionaryEditReq req);

    BasicParamCfg convert(ParamCfgAddReq req);

    BasicParamCfg convert(ParamCfgEditReq req);

    ParamCfgRes convert(BasicParamCfg cfg);

    DictionaryRes convert(BasicDictionary dictionary);

    ConsoleResourceRes convert(BasicRbacResource resource);

    BasicRbacRole convert(RoleAddReq req);

    BasicRbacRole convert(RoleEditReq req);

    RoleRes convert(BasicRbacRole role);

    BasicRbacInterface convert(InterfaceAddReq req);

    BasicRbacInterface convert(InterfaceEditReq req);

    InterfaceRes convert(BasicRbacInterface rbacInterface);

    InterfaceDef convertDef(BasicRbacInterface rbacInterface);

    BasicRbacResource convert(ResourceAddReq req);

    BasicRbacResource convert(ResourceEditReq req);

    @Mapping(target = "resourceTypeName", expression = "java(DictConverter.convert(Dictionary.RESOURCE_TYPE, resource.getResourceType()))")
    ResourceRes convertResourceRes(BasicRbacResource resource);

    UserPageRes convert(UserProfile userProfile);

    UserDetailRes convertUserDetailRes(UserProfile userProfile);

    UserProfile convert(UserAddReq req);

    UserProfile convert(UserEditReq req);

}
